#!/usr/bin/env python3
"""
创建数据库表脚本
"""

import sys
import os

# 添加项目根目录到Python路径
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from app.core.database import Base, engine
from app.models import Grade, KnowledgePoint, Question, TestPaper, TestAttempt, TestPaperQuestion

def create_tables():
    """创建所有数据库表"""
    try:
        print("正在创建数据库表...")
        Base.metadata.create_all(bind=engine)
        print("数据库表创建成功！")
        
        # 显示创建的表
        tables = Base.metadata.tables.keys()
        print("创建的表:")
        for table in tables:
            print(f"  - {table}")
            
    except Exception as e:
        print(f"创建表失败: {e}")

if __name__ == "__main__":
    create_tables()